<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\admin\controller;

abstract class Arcv extends Brcv
{
    public $_app;
    public $_controller;
    public $_action;
    public $_method = "GET";
    public $_header = [];
    public $_token;
    public $_lang = "zh-cn";
    public $_role = "guest";
    public $_host;
    public $_ip;
    public $_user;
    public $_user_id;
    public $_uniacid = 666;
    protected $middleware = ["app\\middleware\\AppInit"];
    protected $autograph = "";
    protected $uniacid = 0;
    public $is_app = 0;
    protected $defaultImage = ["avatar" => "https://lbqnyv2.migugu.com/defaultAvatar.png", "image" => "https://lbqnyv2.migugu.com/lbCardDefaultImage.png"];
    protected $check_url = "";
    protected $_config;
    protected $noNeedLogin = [];
    public function __construct()
    {
    }
    public function shareChangeDatas($input)
    {
        if(!empty($input["pid"]) || $this->is_app == 0) {
            return true;
        }
        $arr = ["massage/app/Index/configInfo", "shop/app/Index/configInfo", "massage/app/Index/index", "massage/app/Index/serviceList", "massage/app/Index/couponList", "massage/app/Index/getMapInfo", "massage/app/Index/serviceCoachList", "massage/app/Index/typeServiceCoachList", "massage/app/Index/getCity", "massage/app/Index/coachServiceList", "massage/app/Index/expectationCityCheck", "massage/app/IndexUser/index", "massage/app/IndexOrder/adapayOrderInfo", "massage/app/IndexUser/channelCateSelect", "massage/app/IndexBalance/cardList", "massage/app/IndexArticle/articleInfo", "massage/app/Index/serviceInfo", "massage/app/Index/serviceCateList", "massage/app/Index/coachInfo", "massage/app/Index/commentList", "massage/app/Index/plugAuth", "dynamic/app/IndexDynamicList/dynamicList", "dynamic/app/IndexDynamicList/getFollowData", "store/app/IndexStore/storeList", "store/app/IndexStore/storeInfo", "store/app/IndexStore/storeServiceList", "store/app/IndexStore/commentList", "massage/app/Index/recommendList", "map/app/Index/coachList", "massage/app/Index/getCoachService", "massage/app/Index/agentInfo", "massage/app/Index/WatermarkImgInfo"];
        if(!empty($input["urls"]) && in_array($input["urls"], $arr)) {
            $input["urls"] = trim(strrchr($input["urls"], "/"), "/");
            $this->noNeedLogin[] = $input["urls"];
        }
        return true;
    }
    public function match($arr)
    {
        $arr = is_array($arr) ? $arr : explode(",", $arr);
        if(!$arr) {
            return false;
        }
        $arr = array_map("strtolower", $arr);
        if(in_array(strtolower($this->request->action()), $arr) || in_array("*", $arr)) {
            return true;
        }
        return false;
    }
    public function _empty($method)
    {
        if(method_exists($this, $method . "_" . $this->method . "_" . $this->type)) {
            $fun = $method . "_" . $this->method . "_" . $this->type;
        } elseif($this->method == $this->restDefaultMethod && method_exists($this, $method . "_" . $this->type)) {
            $fun = $method . "_" . $this->type;
        } elseif($this->type == $this->restDefaultType && method_exists($this, $method . "_" . $this->method)) {
            $fun = $method . "_" . $this->method;
        }
        if(isset($fun)) {
            return \think\App::invokeMethod([$this, $fun]);
        }
        throw new \Exception("error action :" . $method);
    }
    protected function getUserInfo()
    {
    }
    protected function getUserId()
    {
    }
    public function payConfig()
    {
    }
    protected function getTimeData()
    {
    }
    protected function getTimeDataV2($start_time, $end_time, $coach_id, $time_)
    {
        $time_ = (int) $time_;
        $config_model = new \app\massage\model\Config();
        $config = $config_model->dataInfo(["uniacid" => $this->_uniacid]);
        $where = ["start_time" => $start_time, "end_time" => $end_time, "coach_id" => $coach_id, "date" => date("Y-m-d", $time_), "max_day" => $config["max_day"], "time_unit" => $config["time_unit"]];
        $info = \think\facade\Db::name("massage_service_coach_time")->where($where)->find();
        if($info) {
            $info = json_decode($info["info"], true);
            foreach ($info as &$value) {
                $where = [];
                $where[] = ["coach_id", "=", $coach_id];
                $where[] = ["start_time", "<=", $value["time_str"]];
                $where[] = ["end_time", ">=", $value["time_str"]];
                $where[] = ["pay_type", "not in", [-1]];
                $order = \think\facade\Db::name("massage_service_order_list")->where($where)->find();
                if(!empty($order)) {
                    $value["status"] = 0;
                    $value["is_order"] = 1;
                } else {
                    $value["is_order"] = 0;
                }
                $value["status"] = $value["time_str"] < time() ? 0 : $value["status"];
            }
            return $info;
        } else {
            $end_time = strtotime($end_time) - strtotime(date("Y-m-d", time())) + strtotime(date("Y-m-d", $time_));
            $start_time = strtotime($start_time) - strtotime(date("Y-m-d", time())) + strtotime(date("Y-m-d", $time_));
            $end_time = $start_time < $end_time ? $end_time : $end_time + 86400;
            $i = 0;
            $data = [];
            $time = $start_time;
            while ($time < $end_time) {
                $time = $start_time + $config["time_unit"] * $i * 60;
                $times = date("Y-m-d", $time) == date("Y-m-d", $time_) ? $time : $time - 86400;
                if($end_time < $time) {
                    break;
                }
                if(!empty($data[0]) && $times == $data[0]["time_str"]) {
                } else {
                    $data[$i]["time_str"] = $times;
                    $data[$i]["time_text"] = date("H:i", $times);
                    $data[$i]["time_texts"] = date("Y-m-d", $times);
                    $data[$i]["is_click"] = 0;
                    $where = [];
                    $where[] = ["coach_id", "=", $coach_id];
                    $where[] = ["start_time", "<=", $times];
                    $where[] = ["end_time", ">=", $times];
                    $where[] = ["pay_type", "not in", [-1, 7]];
                    $order = \think\facade\Db::name("massage_service_order_list")->where($where)->find();
                    if(!empty($order)) {
                        $data[$i]["is_order"] = 1;
                        $data[$i]["status"] = 0;
                    } else {
                        $data[$i]["is_order"] = 0;
                        $data[$i]["status"] = 1;
                    }
                    $t = "1666281540";
                    $data[$i]["status"] = $times < $t ? 0 : $data[$i]["status"];
                    $i++;
                }
            }
            $data = !empty($data) ? arraySort($data, "time_str") : $data;
            return $data;
        }
    }
    public function getLatData($lng, $lat, $uniacid)
    {
        $key = "getCityByLongLatArr" . round($lng, 4) . "-" . round($lat, 4);
        $value = getCache($key, $uniacid);
        if(!empty($value)) {
            return $value;
        }
        $dis = ["uniacid" => $uniacid];
        $config_model = new \app\massage\model\Config();
        $config = $config_model->dataInfo($dis);
        $map_secret = !empty($config["map_secret"]) ? $config["map_secret"] : "bViFglag7C7G7QlZ1MglFyvh40yK1Tir";
        $URL = "https://apis.map.qq.com/ws/geocoder/v1/?location=" . $lat . "," . $lng . "&key=" . $map_secret;
        $data = longbingCurl($URL, []);
        $data = @json_decode($data, true);
        $arr = [];
        if(!empty($data["result"]["address_component"]["city"])) {
            $arr[] = $data["result"]["address_component"]["city"];
        }
        if(!empty($data["result"]["address_component"]["district"])) {
            $arr[] = $data["result"]["address_component"]["district"];
        }
        if(!empty($arr)) {
            setCache($key, $arr, 86400, $uniacid);
        }
        return $arr;
    }
    public function getAuthList()
    {
    }
}

?>